from requests import post, exceptions
from urllib3 import exceptions as ue

def verify(api_key, password):
    try:
        verifyed = post('http://127.0.0.1:8090/verifyed', data={'api_key':api_key, 'password':password}, timeout=20)
        #print(verifyed.text)
    except exceptions.ConnectTimeout as e:
        return 'requests.exceptions.ConnectTimeout'
    except exceptions.ConnectionError as e2:
        return  'requests.exceptions.ConnectionError'
    except exceptions.ReadTimeout as e3:
        return 'requests.exceptions.ReadTimeout'
    except ue.NameResolutionError as e4:
        return 'urllib3.exceptions.NameResolutionError'
    else:
        if verifyed.text == 'verifyed.':
            return False
        else:
            return True
    
def register(api_key, password):
    try:
        registered = post('http://127.0.0.1:8090/registered', data={'api_key':api_key, 'password':password}, timeout=20)
        #print(registered.text)
    except exceptions.ConnectTimeout as e:
        return 'requests.exceptions.ConnectTimeout'
    except exceptions.ConnectionError as e2:
        return  'requests.exceptions.ConnectionError'
    except exceptions.ReadTimeout as e3:
        return 'requests.exceptions.ReadTimeout'
    except ue.NameResolutionError as e4:
        return 'urllib3.exceptions.NameResolutionError'
    else:
        if registered.text == 'registered':
            return False
        else:
            return True
    
if __name__ == '__main__':
    api_key = input('api_key:')
    password = input('password:')
    print(register(api_key, password))  
    api_key = input('api_key:')
    password = input('password:')
    print(verify(api_key, password))